atspi: Fix up the role for password entries
authorMatthias Clasen <mclasen@redhat.com>
Tue, 13 Oct 2020 14:52:43 +0000 (10:52 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 13 Oct 2020 14:52:43 +0000 (10:52 -0400)
We use to set the the 'password text' role for entries with
visibility = FALSE. Nowadays, we have a separate class for
password entries, so fix up the role mapping based on that.

gtk/a11y/gtkatspicontext.c
gtk/a11y/gtkatspiutils.c
gtk/a11y/gtkatspiutilsprivate.h

index 9a5f58fd47cd2306738a67340bcbbd1f2956e219..aa9b3ccf057d9d84cf663e98056781a3d6e914bb 100644 (file)
@@ -370,8 +370,8 @@ handle_accessible_method (GDBusConnection       *connection,
 
   if (g_strcmp0 (method_name, "GetRole") == 0)
     {
-      GtkAccessibleRole role = gtk_at_context_get_accessible_role (GTK_AT_CONTEXT (self));
-      guint atspi_role = gtk_accessible_role_to_atspi_role (role);
+      guint atspi_role = gtk_atspi_role_for_context (GTK_AT_CONTEXT (self));
+
       g_dbus_method_invocation_return_value (invocation, g_variant_new ("(u)", atspi_role));
     }
   else if (g_strcmp0 (method_name, "GetRoleName") == 0)
index cea75297e51f91416708f3e2432d2ed6335a34d2..f4c854693d989fd0e193c029bc718f54f98b3bb8 100644 (file)
@@ -21,6 +21,8 @@
 #include "config.h"
 
 #include "gtkatspiutilsprivate.h"
+#include "gtkenums.h"
+#include "gtkpasswordentry.h"
 
 /*< private >
  * gtk_accessible_role_to_atspi_role:
@@ -30,7 +32,7 @@
  *
  * Returns: an #AtspiRole
  */
-AtspiRole
+static AtspiRole
 gtk_accessible_role_to_atspi_role (GtkAccessibleRole role)
 {
   switch (role)
@@ -276,6 +278,28 @@ gtk_accessible_role_to_atspi_role (GtkAccessibleRole role)
   return ATSPI_ROLE_FILLER;
 }
 
+/*<private>
+ * gtk_atspi_role_for_context:
+ * @context: a #GtkATContext
+ *
+ * Returns a suitable ATSPI role for a context, taking into account
+ * both the #GtkAccessibleRole set on the context and the type
+ * of accessible.
+ *
+ * Returns: an #AtspiRole
+ */
+AtspiRole
+gtk_atspi_role_for_context (GtkATContext *context)
+{
+  GtkAccessible *accessible = gtk_at_context_get_accessible (context);
+  GtkAccessibleRole role = gtk_at_context_get_accessible_role (context);
+
+  if (GTK_IS_PASSWORD_ENTRY (accessible))
+    return ATSPI_ROLE_PASSWORD_TEXT;
+
+  return gtk_accessible_role_to_atspi_role (role);
+}
+
 GVariant *
 gtk_at_spi_null_ref (void)
 {
index dc8be1cca8c24424be61a911352a1802f67375a2..20b0b093055d2046649b0c042a7133d6b940cab0 100644 (file)
 #pragma once
 
 #include "gtkatspiprivate.h"
-#include "gtkenums.h"
+#include "gtkatcontextprivate.h"
 
 G_BEGIN_DECLS
 
 AtspiRole
-gtk_accessible_role_to_atspi_role (GtkAccessibleRole role);
+gtk_atspi_role_for_context (GtkATContext *context);
 
 GVariant *
 gtk_at_spi_null_ref (void);